package mk.jug.academy.service;

import mk.jug.academy.model.Content;
import mk.jug.academy.model.ContentStatus;
import mk.jug.academy.model.Page;
import mk.jug.academy.model.User;

/**
 * Defines the contract regarding the services revolving
 * around a {@link Content} in the system.
 *
 * @author Ice.Penov
 */
public interface ContentService {
	
	/**
	 * A {@link User} saves a {@link Content}.
	 */
	void save(Content content, User user);
	
	/**
	 * A saved {@link Content} is being published.
	 */
	void publish(Content content);

	/**
	 * A {@link Content} is being deleted (soft).
	 */
	void delete(Content content);
	
	/**
	 * Fetches the {@link ContentStatus#SAVED} {@link Content}s,
	 * in a paged manner, ordered by publishDate.
	 * 
	 * @param pageNumber the number of the page to be retrieved
	 * @param itemsPerPage the count of items per page
	 * @return content items, in a paged structure
	 */
	Page<Content> listSaved(int pageNumber, int itemsPerPage);
	
	/**
	 * Fetches the {@link ContentStatus#PUBLISHED} {@link Content}s, 
	 * in a paged manner, ordered by publishDate.
	 */
	Page<Content> listPublished(int pageNumber, int itemsPerPage);

	/**
	 * Fetches the {@link ContentStatus#DELETED} {@link Content}s, 
	 * in a paged manner, ordered by publishDate.
	 */
	Page<Content> listDeleted(int pageNumber, int itemsPerPage);
	
	/**
	 * Fetches the saved {@link Content}s, in a paged manner,
	 * only for their given creator.
	 * 
	 * @param pageNumber the number of the page
	 * @param itemsPerPage the total number of items on that page
	 * @param creatorID the id of the creator
	 * @return the pages structure of items, for the given creator id
	 */
	Page<Content> listSavedAsCreator(int pageNumber, int itemsPerPage, Long creatorID);
	
	/**
	 * Fetches the published {@link Content}s, in a paged manner,
	 * only for their given creator.
	 * 
	 * @param pageNumber the number of the page
	 * @param itemsPerPage the total number of items on that page
	 * @param creatorID the id of the creator
	 * @return the pages structure of items, for the given creator id
	 */
	Page<Content> listPublishedAsCreator(int pageNumber, int itemsPerPage, Long creatorID);
	
	/**
	 * Fetches the deleted {@link Content}s, in a paged manner,
	 * only for their given creator.
	 * 
	 * @param pageNumber the number of the page
	 * @param itemsPerPage the total number of items on that page
	 * @param creatorID the id of the creator
	 * @return the pages structure of items, for the given creator id
	 */
	Page<Content> listDeletedAsCreator(int pageNumber, int itemsPerPage, Long creatorID);
	
	/**
	 * Gets the {@link Content} by the given ID.
	 */
	Content load(Long id);
	
	/**
	 * Saves the changes.
	 */
	void saveChanges(Content content);

	

}